package com.example.lenovo.activityutil;

import android.app.Activity;
import android.util.Log;

import java.util.ArrayList;

/**
 * Created by Lenovo on 2018/9/21.
 */
public class ActivityCollector {
    private static ArrayList<Activity> activities;
    static {
        activities = new ArrayList<>();
    }

    public static void addActivity(Activity activity){
        activities.add(activity);
    }
    public static void removeActivity(Activity activity){
        activities.remove(activity);
    }

    public static void finishAll(){
        for (Activity activity : activities){
            if(!activity.isFinishing()){
                activity.finish();
            }
        }
        activities.clear();
    }

    public static void printSize(){
        Log.d("activities", "size = "+activities.size());
    }
}
